package com.allen.study.application.api;

import com.allen.study.application.api.request.EmployeeLoginQueryRequest;
import com.allen.study.application.service.EmployeeLoginAppService;
import com.allen.study.test_common.base.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: LoginApi
 * @Author: AllenSun
 * @Date: 2025/3/6 22:45
 */
@RequestMapping()
@RestController
@AllArgsConstructor
@Tag(name = "用户登录接口", description = "用户登录接口")
public class LoginApi {

    private final EmployeeLoginAppService employeeLoginAppService;

    @PostMapping("/login")
    public ApiResponse<String> login(@RequestBody EmployeeLoginQueryRequest request) {
        String token = employeeLoginAppService.login(request).getData();
        return ApiResponse.ok("成功获取token，请复制使用：Bearer "+token);
    }

    @GetMapping("/index")
    @ResponseBody
    public String index(){
        return "用户登录成功";
    }

    // TODO 在security框架中，默认提供了退出登陆的功能。请求地址是 /lohout 此为默认值
    // TODO springSecurity默认登录成功以后如何获取token去调用其他接口
}
